package com.hui.entity.dto;


import com.hui.entity.dao.ShopUser;

import java.util.HashMap;
import java.util.Map;

/**
 * 全局user 本地用户
 */
public class LocalUser {

    private static Map<Long, Object> userInfo = new HashMap<>();

    /**
     * 存放用户信息
     *
     * @param user 用户信息
     */
    public static void setUser(ShopUser user, Long uid) {
        Map<String, Object> map = new HashMap<>();
        map.put("user", user);
        userInfo.put(uid, map);
    }

    /**
     * 获取用户信息
     *
     * @return
     */
    public static ShopUser getUser(Long uid) {
        Map<String, Object> map = (Map<String, Object>) userInfo.get(uid);
        ShopUser user = (ShopUser) map.get("user");
        return user;
    }

}
